<?php

namespace extend\qrcode;

require_once './vendor/phpqrcode/phpqrcode.php';

class ErCode
{

    public function code($string, $fileName = '')
    {

        $data = $string;//内容
        $level = 'L';// 纠错级别：L、M、Q、H
        $size = 10;//元素尺寸
        $margin = 1;//边距
        $outfile = $fileName;
        $back_color = 0xFFFFFF;//白色底色
        $fore_color = 0x000000;//黑色二维码色 若传参数要hexdec处理

        $QRcode = new \QRcode();

        //生成png图片
        $QRcode->png($data, $outfile, $level, $size, $margin, false, $back_color, $fore_color);
    }


}